#include <QtGui>
#include <QTranslator>
#include <QtCore/QTextCodec>
#include "gv_zoneshomedialog.h"
#include "gv_zonesstatusdialog.h"
#include "gv_zonesconfigurationdetaildialog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_ZonesHomeDialog::GV_ZonesHomeDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(BackButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(home()));

    connect(ZoneButton01,SIGNAL(clicked()),this,SLOT(button1Pushed()));
    connect(ZoneButton02,SIGNAL(clicked()),this,SLOT(button1Pushed()));
    connect(ZoneButton03,SIGNAL(clicked()),this,SLOT(button1Pushed()));
    connect(ZoneButton04,SIGNAL(clicked()),this,SLOT(button1Pushed()));

    timer->start(1000);
}
void GV_ZonesHomeDialog::reloadtext()
{
    NameHintsLabel->setText(tr("Zones"));

    BackButton->setText(tr("Back"));
    HelpButton->setText(tr("Help"));
    CancelButton->setText(tr("Cancel"));

    ZoneButton01->setText(tr("Zone1"));
    ZoneButton02->setText(tr("Zone2"));
    ZoneButton03->setText(tr("Zone3"));
    ZoneButton04->setText(tr("Zone4"));
}
void GV_ZonesHomeDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_ZonesHomeDialog::home()
{
    QDialog *dialog1 = new gv_home;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_ZonesHomeDialog::button1Pushed()
{
    QDialog *dialog1 = new GV_ZonesStatusDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
    //TODO

}

